package tw.org.iii.httpimage;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.widget.ImageView;

@SuppressLint("NewApi")
public class ActMain extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.actmain);
		
		StrictMode.ThreadPolicy l_policy = 
				new StrictMode.ThreadPolicy.Builder().permitAll().build();
		 StrictMode.setThreadPolicy( l_policy);

		 ImageView  imgContent=(ImageView)findViewById(R.id.imgContent);
			try {
				
				URL url=new URL("http://farm3.staticflickr.com/2852/11890360243_49b111cbd5_m.jpg");						
				URLConnection conn=url.openConnection();
				InputStream l_streamIn=conn.getInputStream();
				Bitmap pic=BitmapFactory.decodeStream(l_streamIn);
				imgContent.setImageBitmap(pic);

				
			} catch (MalformedURLException e) {
				
				e.printStackTrace();
			}catch (IOException e) {
				
				e.printStackTrace();
			}catch (Exception e) {
				
				e.printStackTrace();
			}
		
		
		
		
		
		
	}

	

}
